package com.x.erp.service;

import com.alibaba.dubbo.config.annotation.Service;
import com.x.erp.dao.InsuranceGoodsDao;
import com.x.erp.model.InsuranceGoods;
import com.x.erp.rpc.InsuranceGoodsRpcService;
import com.x.framework.exception.BusinessException;
import com.x.framework.exception.ExceptionCode;
import com.x.framework.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 延保商品服务
 */
@Component
@Service(interfaceName = "com.x.erp.rpc.InsuranceGoodsRpcService", timeout = 60000)
public class InsuranceGoodsSerVice extends BaseService implements InsuranceGoodsRpcService {

	@Autowired
	private InsuranceGoodsDao insuranceGoodsDao; // 延保商品dao

	/**
	 * 获取延保商品列表
	 *
	 * @param insuranceGoods
	 * @return
	 */
	@Override
	public List<InsuranceGoods> selectInsuranceGoodsList(InsuranceGoods insuranceGoods) {
		try {
			return insuranceGoodsDao.selectInsuranceGoodsList(insuranceGoods);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
		}
	}

	/**
	 * 获取单个延保商品信息
	 *
	 * @param insuranceGoods
	 * @return
	 */
	@Override
	public InsuranceGoods selectInsuranceGoods(InsuranceGoods insuranceGoods) {
		try {
			return insuranceGoodsDao.selectInsuranceGoods(insuranceGoods);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
		}
	}
}
